Format-specific graphics importer components, such as the importers for JPEG, PNG, TIFF etc., are simple components. When a format-specific graphics importer is opened, it opens and targets an instance of the generic importer. Subsequently, it delegates most of its calls to the generic importer instance, as shown in Figure 16-2 .
Figure 2 Delegating calls to the generic importer
The generic importer communicates with data handler components to negotiate access to image file data, and with the Image Compression Manager to arrange for image rendering. The only service a format-specific importer must provide is the GraphicsImportGetImageDescription call, which examines an image file and constructs an image description for it. The generic importer uses this image description to respond to other calls such as GraphicsImportGetNaturalBounds and GraphicsImportDraw . (In the case of GraphicsImportDraw , the image description is passed to the Image Compression Manager, so the cType field must identify a codec that will be able to draw the image. If a graphics importer needs to pass extra information that the codec will need at PreDecompress time, it can pass it in an image description extension.)
Graphics importer components may override other calls, such as GraphicsImportGetMetaData , which extracts supplemental information from an image file, and GraphicsImportGetMIMETypeList , which provides information about the format.
Another optional call is GraphicsImportValidate , which attempts to ascertain quickly whether a file matches the importer's format. This is especially useful for formats which start with identifying codes or "magic numbers" (such as PNG and TIFF) in situations where image files do not have helpful file types or suffixes. In situations like this, the Image Compression Manager may ask many graphics importers in turn to validate until it finds one that accepts the file, so it is important that GraphicsImportValidate calls not be too slow.
Graphics importers supporting image formats which can have transparent regions should implement the GraphicsImportDoesDrawAllPixels call so as to warn applications that they may need to erase the destination area before drawing.
| Previous | Chapter Contents | Chapter Top | Next |